
<h1><span class="yiyi-st" id="yiyi-12">numpy.logical_xor</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.logical_xor.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.logical_xor.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="data">
<dt id="numpy.logical_xor"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">logical_xor</code><span class="sig-paren">(</span><em>x1</em>, <em>x2</em><span class="optional">[</span>, <em>out</em><span class="optional">]</span><span class="sig-paren">)</span><em class="property"> = &lt;ufunc &apos;logical_xor&apos;&gt;</em></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">按元素方式计算x1 XOR x2的真值。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-15">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-16"><strong>x1，x2</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-17">逻辑异或应用于<em class="xref py py-obj">x1</em>和<em class="xref py py-obj">x2</em>的元素。</span><span class="yiyi-st" id="yiyi-18">它们必须可以广播到相同的形状。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-19">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-20"><strong>y</strong>：bool或ndarray的bool</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-21">应用于<em class="xref py py-obj">x1</em>和<em class="xref py py-obj">x2</em>的元素的逻辑异或运算的布尔结果；该形状由是否需要广播一个或两个数组来确定。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-22">也可以看看</span></p>
<p class="last"><span class="yiyi-st" id="yiyi-23"><a class="reference internal" href="numpy.logical_and.html#numpy.logical_and" title="numpy.logical_and"><code class="xref py py-obj docutils literal"><span class="pre">logical_and</span></code></a>，<a class="reference internal" href="numpy.logical_or.html#numpy.logical_or" title="numpy.logical_or"><code class="xref py py-obj docutils literal"><span class="pre">logical_or</span></code></a>，<a class="reference internal" href="numpy.logical_not.html#numpy.logical_not" title="numpy.logical_not"><code class="xref py py-obj docutils literal"><span class="pre">logical_not</span></code></a>，<a class="reference internal" href="numpy.bitwise_xor.html#numpy.bitwise_xor" title="numpy.bitwise_xor"><code class="xref py py-obj docutils literal"><span class="pre">bitwise_xor</span></code></a></span></p>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-24">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">logical_xor</span><span class="p">(</span><span class="kc">True</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">logical_xor</span><span class="p">([</span><span class="kc">True</span><span class="p">,</span> <span class="kc">True</span><span class="p">,</span> <span class="kc">False</span><span class="p">,</span> <span class="kc">False</span><span class="p">],</span> <span class="p">[</span><span class="kc">True</span><span class="p">,</span> <span class="kc">False</span><span class="p">,</span> <span class="kc">True</span><span class="p">,</span> <span class="kc">False</span><span class="p">])</span>
<span class="go">array([False,  True,  True, False], dtype=bool)</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">logical_xor</span><span class="p">(</span><span class="n">x</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">array([ True, False, False, False,  True], dtype=bool)</span>
</pre></div>
</div>
<p><span class="yiyi-st" id="yiyi-25">显示广播支持的简单示例</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">logical_xor</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="go">array([[ True, False],</span>
<span class="go">       [False,  True]], dtype=bool)</span>
</pre></div>
</div>
</dd></dl>
